package monitor

import (
	"os"
	"time"
)

const (
	// CPUAll is for reading all cpu jiffies
	CPUAll = 0
	// CPUSum is just read one sum of cpu jiffies
	CPUSum = 1
)

var osPageSize int = 4096

func init() {
	osPageSize = os.Getpagesize()
}

// MemInfo for os memory
type MemInfo struct {
	total, free             uint64
	shared, buffers, cached uint64
	stamp                   time.Time
}

// CPUInfo for cpu calc
type CPUInfo struct {
	usr, nice, sys, idle        uint64
	iowait, irq, softirq, steal uint64
	total, busy                 uint64
	stamp                       time.Time
}

// ProcessInfo for Process calc
type ProcessInfo struct {
	pid          int
	name         string
	state        string
	utime, stime uint64
	vsize, rss   uint64
	startTime    uint64
	sysCPUTime   uint64
	sysCPUNum    int
	sysMemSize   uint64
	stamp        time.Time
}

// SysInfo is an interface for OS
type SysInfo interface {
	Init()
	GetCPUNum() int
	GetProcessPids(names []string) (map[string][]int, error)
	GetMemInfo(*MemInfo) error
	GetCPUInfo(int, []CPUInfo) (int, error)
	GetProcessInfo(int, *ProcessInfo) error
}
